import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;

public class door  extends Actor
{
    GreenfootImage buffer;
    int counter=0,height=0;
    boolean opening=false;
    
    public door(int h,int r){
        setRotation(r);
        height=h;
        buffer = new GreenfootImage(4,h);
        setImage(buffer);
        buffer.drawLine(0,0,0,200);
        buffer.drawLine(3,0,3,200);
        buffer.setColor(new Color(50,50,128));
        buffer.fillRect(1,0,2,200);
    }

    public void act() 
    {
        if(opening){
            buffer.setColorAt(1,counter,new Color(0,0,0,0));
            buffer.setColorAt(2,counter,new Color(0,0,0,0));
            counter++;
            if(counter==height)opening=false;
        }
    }    
    
    public void open(){
        if(counter==0)opening=true;
    }
    
    
}
